package com.efast.dmom.mgmt.controller.mes;

import java.util.List;
import java.util.Map;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.mes.InfPpPlan;
import com.efast.dmom.mgmt.entity.mes.TwPlanSplit;
import com.efast.dmom.mgmt.entity.mes.TwProductionPlan;
import com.efast.dmom.mgmt.service.mes.TwProductionPlanService;
import com.itextpdf.text.log.SysoCounter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/twProductionPlan")
public class TwProductionPlanController {

	@Autowired
	private TwProductionPlanService twProductionPlanService;

	// 计划关闭计划单状态改为close
	@RequestMapping(value = "/planColsed")
	public @ResponseBody ResultBean planColsed(@RequestBody TwProductionPlan twProductionPlan) {
		ResultBean result = new ResultBean(true, "'");
		twProductionPlanService.planColsed(twProductionPlan);
		return result;
	}

	// 计划生成工单
	@RequestMapping(value = "/planMakeWorkOrder")
	public @ResponseBody ResultBean planMakeWorkOrder(@RequestBody TwPlanSplit twPlanSplit) {
		ResultBean result = new ResultBean(true, "'");
		twProductionPlanService.planMakeWorkOrder(twPlanSplit);
		return result;
	}

	// 长江车场 更新计划
	@RequestMapping(value = "/updatePlanCreate")
	public @ResponseBody ResultBean updatePlanCreate(@RequestBody Map<String, Object> map) {
		ResultBean result = twProductionPlanService.updatePlanCreate(map);
		return result;
	}

	// 长江车场 删除计划
	@RequestMapping(value = "/deletePlanCreate")
	public @ResponseBody ResultBean deletePlanCreate(@RequestBody Map<String, Object> map) {
		ResultBean result = new ResultBean(true, "'");
		twProductionPlanService.deletePlanCreate(map);
		return result;
	}

	// 长江车场 计划生成工单
	@RequestMapping(value = "/planWorkOrder")
	public @ResponseBody ResultBean planWorkOrder(@RequestBody Map<String, Object> map) {
		ResultBean result=twProductionPlanService.planWorkOrder(map);
		return result;
	}

	// 长江车场 拆分工单并计划生成工单
	@RequestMapping(value = "/planWorkOrder/{splitQty}/{singerOrderQty}")
	public @ResponseBody ResultBean planWorkSplitOrder(@RequestBody Map<String, Object> map,@PathVariable("splitQty")Integer splitQty,@PathVariable("singerOrderQty")Integer singerOrderQty) {
		ResultBean result = new ResultBean(true, "'");
		twProductionPlanService.planWorkSplitOrder(map,splitQty,singerOrderQty);
		return result;
	}

	// 长江车场 计划排序
	@RequestMapping(value = "/PlanSort")
	public @ResponseBody ResultBean PlanSort(@RequestBody Map<String, Object> map) {
		ResultBean planSort = twProductionPlanService.PlanSort(map);
		return planSort;
	}

	// 长江车场计划新增
	@RequestMapping(value = "/PlanAdd")
	public @ResponseBody ResultBean PlanAdd(@RequestBody InfPpPlan infPpPlan) {
		ResultBean result = twProductionPlanService.insertPlanCreate(infPpPlan);
		return result;
	}

}
